package br.ufrgs.inf.engsoft.stp.exchange;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@SuppressWarnings("serial")
@Entity
@Table(name = "stp_exchange")
public class Exchange implements Serializable {
    
	public static final int PROPOSED = 0;
	public static final int COMPLETED = 1;
	public static final int REJECTED = 2;
	
	@Id
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
	
	@Column(name = "p1_id", nullable = false)
	private Long p1Id;
	
	@Column(name = "p2_id", nullable = false)
    private Long p2Id; 
	
	@Column(name = "status", nullable = false)
	private Integer status;
	
	public Exchange() {
		this.id = (new Date()).getTime();
	}
	
	public Exchange(Long p1, Long p2) {
		this.id = (new Date()).getTime();
		this.p1Id = p1;
		this.p2Id = p2;
		this.status = PROPOSED;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Long getProduct1Id() {
		return p1Id;
	}

	public void setProduct1Id(Long p1Id) {
		this.p1Id = p1Id;
	}

	public Long getProduct2Id() {
		return p2Id;
	}

	public void setProduct2Id(Long p2Id) {
		this.p2Id = p2Id;
	}

	public Long getId() {
		return id;
	}
}